package com.linjacy.container.product.controller;

import com.linjacy.common.utils.PageUtils;
import com.linjacy.common.utils.R;
import com.linjacy.container.product.entity.TransporterEntity;
import com.linjacy.container.product.entity.UserEntity;
import com.linjacy.container.product.service.TransporterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("product/transporter/info")
public class TransporterController {
    @Autowired
    private TransporterService transporterService;
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = transporterService.queryPage(params);

        return R.ok().put("page", page);
    }
    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@Validated @RequestBody TransporterEntity transporterEntity){
        transporterService.saveTransporter(transporterEntity);
        return R.ok();
    }
    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody TransporterEntity transporterEntity){
        transporterService.updateById(transporterEntity);
        return R.ok();
    }
    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody TransporterEntity transporterEntity){
        int i = transporterService.deleteById(transporterEntity);
        return R.ok().put("result",i);
    }

}
